package com.dsdl.chatapp.module.main;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.dsdl.chatapp.BaseActivity;
import com.dsdl.chatapp.R;
import com.dsdl.chatapp.module.chat.ChatWindowActivity;
import com.dsdl.chatapp.module.login.LoginActivity;
import com.dsdl.chatapp.common.utils.ActivityUtils;
import com.dsdl.chatapp.common.utils.LogUtil;

public class MainActivity extends BaseActivity implements View.OnClickListener,RadioGroup.OnCheckedChangeListener {
    private static String TAG = MainActivity.class.getSimpleName();

    private FrameLayout mFrameLayout;
    private RadioGroup mRadioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mFrameLayout = (FrameLayout) findViewById(R.id.contentFrame);
        mRadioGroup = (RadioGroup) findViewById(R.id.rg_tab);
        mRadioGroup.setOnCheckedChangeListener(this);
        ((RadioButton)mRadioGroup.getChildAt(0)).setChecked(true);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            default:
                break;
        }
    }


    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        switch (i){
            case R.id.rb_tab_msg:
                ChatListFragment chatListFragment = ChatListFragment.newInstance();
                ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),chatListFragment,R.id.contentFrame);
                break;
            case R.id.rb_tab_contacts:
//                ContactsFragment contactsFragment = ContactsFragment.newInstance();
//                ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),contactsFragment,R.id.contentFrame);
                startActivity(new Intent(this,ChatWindowActivity.class));
                break;
            case R.id.rb_tab_self:
//                SelfFragment selfFragment = (SelfFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
//                ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),selfFragment,R.id.contentFrame);
                startActivity(new Intent(this, LoginActivity.class));
                break;
            default:
                break;
        }
    }
}
